#include "MovingWindowSNPBased.h"

using namespace std;

// window = # of markers per set, step = # of markers moved per step 
SetID_SNP::SetID_SNP(vector<MapField*> vec, unsigned int window, unsigned int step){
	populate_set(vec);
	int setid_index = 0;
	for (int i = 0; i != 27; i++){
		if (vec_map.at(i).empty()){
			continue;
		}
		unsigned int window_start = 0;
		unsigned int window_end = window;
		while (window_start < vec_map.at(i).size()){
			for (unsigned int j = window_start; j < window_end; j++){
				try {
					setidvec.push_back(new MarkerSet(setid_index, vec_map.at(i).at(j)));
				}
				catch(out_of_range& oor){
					break;
				}
			}
			setid_index++;
			window_start+=step;
			window_end+=step;
		}
	}
}

void SetID_SNP::populate_set(vector<MapField*> vec){
	for (int i = 0; i !=  27; i++){
		vector<MapField*> temp_map;
		temp_map.clear();
		vec_map[i] = temp_map;
	}

	for (auto it = vec.begin(); it != vec.end(); it++){
		vec_map.at((*it)->get_chr()).push_back(*it);
	}
}

